$(function(){
	initFormValidator();
});

function initFormValidator(){
	  $('#loginForm').bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            "user.account": {
                validators: {
                    notEmpty: {
                        message: '请输入账户!'
                    }
                }
            },
            "user.password": {
                validators: {
                    notEmpty: {  
                        message: '请输入密码!'
                    }
                }
            }
        }
	  }).on('success.form.bv', function(e) {
          e.preventDefault();
          var $form = $(e.target);
          var params = $form.serializeArray();
          $.post(basePath+"login/doLogin.htm",params,function(data){
        	  if(data.status == 'error'){
            	  toastr.error("登录异常:"+data.message);
              }else{
            	  window.location.href=basePath+"index.htm";
              }
          },"json");
          return false; 
      });
}